<?php
namespace Home\Controller;

class PropertyController extends HomeController {
    public function index(){
    	$banner = M("Ad")->where(array('id'=>5))->find();
        $this->assign('banner',$banner);
        $this->display();
    }

    public function detail(){
    	$id = I('get.id');
        if ($id=='' || !is_numeric($id)) {
            $this->error('参数错误');
        }

        $map['id'] = $id;
        $map['show'] = 1;    
        $list = M('Property')->where($map)->find();
        if (!$list) {
            $this->error('信息不存在');
        }else{

            $list['image'] = explode(",", $list['image']);
            unset($map);
            $map['disID'] = $id;
            $map['cid']=3;
            $count = M('Feedback')->where($map)->count();
            $list['count'] = $count+20;

            $map['cid']=4;
            $count = M('Feedback')->where($map)->count();
            $list['count1'] = $count+20;

            $list['total'] = $list['count']+$list['count1'];
            $this->assign('list',$list);

            $banner = M("Ad")->where(array('id'=>5))->find();
        	$this->assign('banner',$banner);

        	//案例
        	unset($map);
        	$map['propertyID'] = $id;
        	$map['show']=1;
        	$case = M('Case')->where($map)->order('sort asc,id desc')->limit(6)->select();
        	$this->assign('case',$case);
        	//设计师
        	unset($map);
        	$map['propertyID'] = $id;
        	$map['show']=1;
        	$desID = M('Case')->where($map)->order('sort asc,id desc')->group('designerID')->limit(5)->getField('designerID',true);
           	unset($map);
            if ($desID) {
                $map['id'] = array('in',$desID);
                $map['show'] = 1;
                $designer = M('Designer')->where($map)->order('sort asc,id desc')->limit(5)->select();
                $this->assign('designer',$designer);
            }        	
            $this->display();
        }
    }
}